import { Component, Input, Output, EventEmitter } from '@angular/core'
import { Social } from '../../providers/social.service';

@Component({
  selector: 'social-share',
  templateUrl: 'social-share.html'
})

export class SocialShareCompontent {

  @Input() shareConfig;
  @Output() onCancel = new EventEmitter<any>();

  constructor(
    public social: Social,
  ) {

  }

  share(type, scene = 1) {
    this.social.share(type, {
      url: 'http://qunen.kuaimacode.com/wap/', // 必选
      title: '这个是 Cordova QQ 新闻分享的标题', // 必选
      description: '这个是 Cordova QQ 新闻分享的描述', // 必选
      image: 'https://cordova.apache.org/static/img/cordova_bot.png',// 必选
      scene: scene, // 微信可选 0=>好友(默认),1=>朋友圈
    })
      .then(res => {
        console.log('分享成功')
      })
      .catch(err => {
        console.log(err)
      })
  }

  bindCancel() {
    this.onCancel.emit()
  }


}